import { PAGE_PATH } from "@/constants";
import Article from "@/views/Article.vue";
import Collect from "@/views/Collect.vue";
import Detail from "@/views/Detail.vue";
import Layout from "@/views/Layout.vue";
import Like from "@/views/Like.vue";
import Login from "@/views/Login.vue";
import NotFound from "@/views/NotFound.vue";
import Register from "@/views/Register.vue";
import User from "@/views/User.vue";
import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);
const router = new VueRouter({
  routes: [
    {
      path: "/",
      redirect: PAGE_PATH.LAYOUT_PAGE,
    },
    {
      path: PAGE_PATH.LOGIN_PAGE,
      component: Login,
    },
    {
      path: PAGE_PATH.REGISTER_PAGE,
      component: Register,
    },
    {
      path: PAGE_PATH.DETAIL_PAGE,
      component: Detail,
    },
    {
      path: PAGE_PATH.LAYOUT_PAGE,
      component: Layout,
      children: [
        {
          path: "",
          redirect: PAGE_PATH.ARTICLE_PAGE,
        },
        {
          path: PAGE_PATH.ARTICLE_PAGE,
          component: Article,
        },
        {
          path: PAGE_PATH.COLLECTION_PAGE,
          component: Collect,
        },
        {
          path: PAGE_PATH.LIKE_PAGE,
          component: Like,
        },
        {
          path: PAGE_PATH.USER_PAGE,
          component: User,
        },
      ],
    },
    {
      path: "*",
      component: NotFound,
    },
  ],
  mode: "history",
  linkActiveClass: "active",
  linkExactActiveClass: "exact-active",
});

export default router;
